import React from 'react'
import { Modal, Form, Input } from 'antd'
const FormItem = Form.Item
class NewModal extends React.Component{
	constructor(props){
		super(props)
		this.state = {
			
		}
	}
	onOk=()=>{
		const { depId,addDeps } = this.props	
		const {validateFields,getFieldsValue,getFieldError}=this.props.form
		validateFields((errors) => {
			if(errors){
				return
			}
			const params=getFieldsValue()
			params.organizationId = depId
			addDeps(params)
		})
	}	
	render(){
		const {getFieldDecorator}=this.props.form
		const { visible1,onCancel } = this.props
		const formItemLayout = {
          labelCol: {
            span: 6
          },
          wrapperCol: {
            span: 14
          }
        }
		const modalProps = {
			  title:'新增部门',
	          visible:visible1,
	          onOk: this.onOk,
	          onCancel: onCancel,
	          wrapClassName: 'vertical-center-modal'
		}
		return(
			<Modal {...modalProps}>
				<Form>
					<FormItem label='部门名字' hasFeedback {...formItemLayout}>
						{getFieldDecorator('name',{
							rules:[
								{
									required:true,
									message:'部门名字未填写'
								}
							]	
							})(
								<Input />
							)}
					</FormItem>
				</Form>
			</Modal>
		)
	}
}

export default Form.create()(NewModal)
